/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
import model.beans.Paciente;

/**
 *
 * @author kelyane
 */
public class PacienteComboboxModel extends AbstractListModel<Paciente> implements ComboBoxModel<Paciente>{
    
    private List<ListDataListener> listeners = new ArrayList<>();
    private List<Paciente> pacientes = new ArrayList<>();
    private Object selectedElement;
    
    @Override
    public void addListDataListener(ListDataListener l) {
        listeners.add(l);
    }
    
    public void addRow(Paciente paciente){
        pacientes.add(paciente);
    }
    
    @Override
    public int getSize() {
        return pacientes.size();
    }

    @Override
    public Paciente getElementAt(int index) {
        return pacientes.get(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selectedElement = anItem;
        System.out.println("Estou no setSelectedItem");
    }

    @Override
    public Object getSelectedItem() {
        return selectedElement;
    }

    
}
